namespace KinonekoSoftware.CodariaDB.Documents.Personalities
{
    /// <summary>
    /// 用于描述喜好程度
    /// </summary>
    public sealed class Degree : Preference, ICloneable<Degree>
    {
        private int _value;

        public Degree Clone()
        {
            return new Degree
            {
                Id        = Id,
                Name      = Name,
                SyncFlags = SyncFlags,
            };
        }

        /// <summary>
        /// 获取或设置 <see cref="Value"/> 属性。
        /// </summary>
        public int Value
        {
            get => _value;
            set => SetValue(ref _value, value);
        }
    }

    public sealed class DegreeGroup : PreferenceGroup
    {
        public override PreferenceGroup Clone()
        {
            var id = string.IsNullOrEmpty(Id) ? ID.Get() : Id;
            return new DegreeGroup
            {
                Id    = id,
                Items = new List<Degree>(Items.Select(x => x.Clone())),
                Intro = Intro,
                Name  = Name,
            };
        }

        public override int          Count => Items?.Count ?? 0;
        public          List<Degree> Items { get; set; }
    }
}